<!--找政策-->
<template>
	<view>
		<view class="white px-20 pt-8 pb-10 mb-6">
			<!--搜索-->
			<view class="white">
				<tm-input v-model="status.keyWord" @confirm="resetReq(false); getData()" :text="false"
					:input-padding="[4, 2]" color="#F7F7F7" font-color="#0073FF" focus-color="#F7F7F7" :round="3"
					:height="61" placeholder="请输入关键字词">
					<template v-slot:left>
						<tm-icon class="px-24" name="tmicon-search" color="#0073FF"></tm-icon>
					</template>
					<template v-slot:right>
						<view class="pl-24"><tm-button @click="resetReq(true); getData()" :round="3" font-color="#0073FF"
								:transprent="true" :width="125" :height="56" color="blue" :margin="[0, 0]" :padding="[0, 0]"
								label="取消"></tm-button></view>
					</template>
				</tm-input>
			</view>
		</view>
		<view style="height:31rpx;"></view>
		<view v-if="list.length > 0">
			<block v-for="(item, index) in list" :key="index">
				<navigator :url="'../news/xiangqing?id='+item.id" v-if="item?.image" class="mx-24 c_bordr-b-1 pb-29 mb-24 flex flex-row flex-row-center-start">
					<view class="c_xwimg flex-shrink">
						<tm-image :round="3" :width="234" :height="176" :src="item.image"></tm-image>
					</view>
					<view class="ml-24 flex-1 flex flex-col" style="align-self: stretch;">
						<view class="flex-1">
							<view class="text-size-g c_danhei c_hight text-overflow-2 flex-1">{{ item.title }}</view>
						</view>
						<view class="c_qianhui text-size-n mt-12">{{ item.created_at }}</view>
					</view>
				</navigator>
				<!--无图片列表-->
				<navigator :url="'../news/xiangqing?id='+item.id" v-else class="mx-24 c_bordr-b-1 pb-29 mb-24  flex flex-col">
					<view class="flex-1">
						<view class="text-size-g c_danhei text-overflow-2 ">
							{{ item.title }}
						</view>
					</view>
					<view class="c_qianhui text-size-n mt-50">{{ item.created_at }}</view>
				</navigator>
			</block>
		</view>


		<bl-list-layout btn-color="white" @restart-load="resetReq(true); getData()" :status="status"
			:list-len="list.length"></bl-list-layout>

	</view>
</template>

<script lang="ts" setup>
import { ref, watch } from "vue"
import { onLoad, onPullDownRefresh, onReachBottom, onShow } from "@dcloudio/uni-app";
import blListLayout from "@/components/bl-list-layout.vue";
import { apiUr, useReqList } from "@/libs/api";
const { status, resetReq, actionHttp, list, setOptions, category, banner } = useReqList();


onLoad(async () => {
	getData()
})

onPullDownRefresh(() => {
	if (status.isLoading) {
		uni.stopPullDownRefresh();
		return
	}
	resetReq(true);
	getData()
})
onReachBottom(() => {
	if (status.isLoading || !status.isMore) return;
	getData()
})

function getData() {
	uni.showLoading({ title: "...", mask: true })
	actionHttp(apiUr.getNewIndex(), { cid: 1 }).then(() => {
		uni.stopPullDownRefresh();
		uni.hideLoading()
		
	})
}



function toLinks(item: any) {
	let stabs = ["index/index", "chengguo/index", "news/index", "user/index"]
	let isStabs = false;
	for (let i = 0; i < stabs.length; i++) {
		isStabs = item.link.indexOf(stabs[i]) > -1 ? true : false;
		if (isStabs) {
			break;
		}
	}
	try {
		if (isStabs) {
			uni.reLaunch({
				url: item.link
			})
		} else {
			uni.navigateTo({
				url: item.link
			})
		}
	} catch (error) {
		console.error(error)
	}
}
</script>
<style>
page,
body {
	background-color: #F7F7F7;
}
</style>

<style lang="less" scoped>
.c_xwimg {
	width: 234rpx;
	height: 176rpx;
}



.c_bordr-b-1 {
	border-bottom: 1px solid #D8D8D8;
}
</style>